package com.gin.no_gay_alliance.manager.provider;

import com.gin.nga.resource.BbsCodeCoreProvider;
import com.gin.nga.resource.BbsIndexProvider;
import com.gin.nga.resource.CommonUiProvider;
import com.gin.nga.resource.ResourceProvider;
import com.gin.no_gay_alliance.app.MyApplication;

import java.io.File;
import java.util.concurrent.TimeUnit;

/**
 * 静态资源管理器
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/25 15:03
 **/
public class ResourceManager {
    /**
     * 缓存过期时长
     */
    public static final long EXPIRES = TimeUnit.HOURS.toMillis(6);

    public static BbsCodeCoreProvider bbsCodeCoreProvider() {
        return new BbsCodeCoreProvider(MyApplication.app.okHttpClient
                , ResourceManager.getRecourceCacheFile("bbs_code_core.json")
                , EXPIRES);
    }

    public static CommonUiProvider commonUiProvider() {
        return new CommonUiProvider(MyApplication.app.okHttpClient
                , ResourceManager.getRecourceCacheFile("common_ui.json")
                , EXPIRES);
    }

    public static BbsIndexProvider bbsIndexProvider() {
        return new BbsIndexProvider(MyApplication.app.okHttpClient
                , ResourceManager.getRecourceCacheFile("bbs_index_data.json")
                , EXPIRES);
    }

    public static File getRecourceCacheFile(String filename) {
        return new File(MyApplication.app.getDataDir(ResourceProvider.class.getSimpleName()), filename);
    }


}
